package com.ruoyi.game.utils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class ValidateTime {
    //时间戳验证
    public Boolean validateTime(String timestamp){
        return isWithinTimeRange(Long.parseLong(timestamp), System.currentTimeMillis(), 120);

    }

    public static boolean isWithinTimeRange(long timestamp1, long timestamp2, long rangeInSeconds) {
        long diffInSeconds = Math.abs(timestamp2 - timestamp1) / 1000; // 转换为秒
        return diffInSeconds <= rangeInSeconds;
    }

}
